package com.example.demo.controller;

import com.example.demo.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class IndexController {
    String url="zhipage/";
    @GetMapping("/")
    public String index(HttpSession session, Model model){
        User user= (User) session.getAttribute("user");
        model.addAttribute("user",user);
        return "index";
    }

    @GetMapping("/login")
    public String login(){
        return "login";
    }

    //退出登录
    @GetMapping("/tulogin")
    public String tulogin(HttpSession session){
        session.removeAttribute("user");
        return "login";
    }



    @GetMapping("/grid_options")
    public String grid_options(HttpSession session, Model model){
        User user= (User) session.getAttribute("user");
        model.addAttribute("user",user);
        return url+"grid_options";
    }

    @GetMapping("/text")
    public String text(HttpSession session, Model model){
        User user= (User) session.getAttribute("user");
        model.addAttribute("user",user);
        return url+"text";
    }
    @GetMapping("/ecommerce_product_list")
    public String ecommerce_product_list(HttpSession session, Model model){
        User user= (User) session.getAttribute("user");
        model.addAttribute("user",user);
        return url+"ecommerce_product_list";
    }
    @GetMapping("/ecommerce_product")
    public String ecommerce_product(HttpSession session, Model model){
        User user= (User) session.getAttribute("user");
        model.addAttribute("user",user);
        return url+"ecommerce_product";
    }
    @GetMapping("/ecommerce_product_detail")
    public String ecommerce_product_detail(HttpSession session, Model model){
        User user= (User) session.getAttribute("user");
        model.addAttribute("user",user);
        return url+"ecommerce_product_detail";
    }
    @GetMapping("/basic_gallery")
    public String basic_gallery(HttpSession session, Model model){
        User user= (User) session.getAttribute("user");
        model.addAttribute("user",user);
        return url+"basic_gallery";
    }
    @GetMapping("/slick_carousel")
    public String slick_carousel(HttpSession session, Model model){
        User user= (User) session.getAttribute("user");
        model.addAttribute("user",user);
        return url+"slick_carousel";
    }
    @GetMapping("/carousel")
    public String carousel(HttpSession session, Model model){
        User user= (User) session.getAttribute("user");
        model.addAttribute("user",user);
        return url+"carousel";
    }
    @GetMapping("/css_animation")
    public String css_animation(HttpSession session, Model model){
        User user= (User) session.getAttribute("user");
        model.addAttribute("user",user);
        return url+"css_animation";
    }

}

